package uczelniabd2;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.Task;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.TableModel;

// =============================================================================
/**
 * The application's main frame.
 */
public class UczelniaBD2View extends FrameView
{

    public UczelniaBD2View(SingleFrameApplication app)
    {
        super(app);

        initComponents();

		// <editor-fold defaultstate="collapsed" desc="Resources, busy icons">
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++)
        {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener()
        {
            public void propertyChange(java.beans.PropertyChangeEvent evt)
            {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName))
                {
                    if (!busyIconTimer.isRunning())
                    {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                }
                else if ("done".equals(propertyName))
                {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                }
                else if ("message".equals(propertyName))
                {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                }
                else if ("progress".equals(propertyName))
                {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
		// </editor-fold>

		mDatabaseMgr = new DatabaseMgr();

		// --- blok wydobywania tabeli z bazy danych START ---
//		String[][] table = mDatabaseMgr.GetTableColumnNames("INSTYTUT", 1);
//		int maxRows = table.length;
//		int maxCols = 0;
//		if(maxRows > 0)
//		{
//			maxCols = table[0].length;
//		}
//		for(int rows = 0; rows < maxRows; rows++)
//        {
//			System.out.print("Wiersz "+rows+": ");
//			for(int cols = 0; cols < maxCols; cols++)
//			{
//				System.out.print(table[rows][cols]+" ");
//			}
//			System.out.println("");
//        }
		// --- blok wydobywania tabeli z bazy danych STOP ---

		// JDBC TABLE TEST
		//prepareAndShowTable("INSTYTUT");
    }
// =============================================================================
	public void prepareAndShowTable(String tableName)
	{
        showTable(prepareTable(tableName));
	}
// =============================================================================
	public TableModel prepareTable(String tableName)
	{
		TableModel tableModel = null;
		try
		{
			mDatabaseMgr.Connect();
			Connection conn = mDatabaseMgr.GetConnection();
			tableModel = new JDBCTableModel (conn, tableName);
			mDatabaseMgr.Disconnect();
		}
		catch (Exception e)
		{
			mDatabaseMgr.Disconnect();
			e.printStackTrace();
		}
		return tableModel;
	}
// =============================================================================
	public void showTable(TableModel tableModel)
	{
		if(mJTable != null)
		{
			mScrollPane.remove(mJTable);
		}
		mJTable = null;
		mJTable = new JTable(tableModel);
		mScrollPane.add(mJTable);
		mScrollPane.setViewportView(mJTable);
	}
// =============================================================================
    @Action
    public void showAboutBox()
    {
        if (aboutBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            aboutBox = new UczelniaBD2AboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(aboutBox);
    }
// =============================================================================
	@Action
    public void showAddStudentBox()
    {
        if (addStudentBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            addStudentBox = new UczelniaBD2AddStudentBox(mainFrame, mDatabaseMgr);
            addStudentBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(addStudentBox);
    }
// =============================================================================
	@Action
    public void showEditStudentBox()
    {
        if (editStudentBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            editStudentBox = new UczelniaBD2EditStudentBox(mainFrame, mDatabaseMgr);
            editStudentBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(editStudentBox);
    }
// =============================================================================
	@Action
    public void showRemoveStudentBox()
    {
        if (removeStudentBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            removeStudentBox = new UczelniaBD2RemoveStudentBox(mainFrame, mDatabaseMgr);
            removeStudentBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(removeStudentBox);
    }
// =============================================================================
	@Action
    public void showAddMajsterBox()
    {
        if (addMajsterBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            addMajsterBox = new UczelniaBD2AddMajsterBox(mainFrame, mDatabaseMgr);
            addMajsterBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(addMajsterBox);
    }
// =============================================================================
	@Action
    public void showEditMajsterBox()
    {
        if (editMajsterBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            editMajsterBox = new UczelniaBD2EditMajsterBox(mainFrame, mDatabaseMgr);
            editMajsterBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(editMajsterBox);
    }
// =============================================================================
	@Action
    public void showRemoveMajsterBox()
    {
        if (removeMajsterBox == null)
        {
            JFrame mainFrame = UczelniaBD2App.getApplication().getMainFrame();
            removeMajsterBox = new UczelniaBD2RemoveMajsterBox(mainFrame, mDatabaseMgr);
            removeMajsterBox.setLocationRelativeTo(mainFrame);
        }
        UczelniaBD2App.getApplication().show(removeMajsterBox);
    }
// =============================================================================
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        mScrollPane = new javax.swing.JScrollPane();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenu7 = new javax.swing.JMenu();
        jMenuItem17 = new javax.swing.JMenuItem();
        jMenuItem18 = new javax.swing.JMenuItem();
        jMenuItem19 = new javax.swing.JMenuItem();
        jMenuItem20 = new javax.swing.JMenuItem();
        jMenu8 = new javax.swing.JMenu();
        jMenuItem21 = new javax.swing.JMenuItem();
        jMenuItem22 = new javax.swing.JMenuItem();
        jMenuItem23 = new javax.swing.JMenuItem();
        jMenuItem24 = new javax.swing.JMenuItem();
        jMenu9 = new javax.swing.JMenu();
        jMenuItem25 = new javax.swing.JMenuItem();
        jMenuItem26 = new javax.swing.JMenuItem();
        jMenuItem27 = new javax.swing.JMenuItem();
        jMenuItem28 = new javax.swing.JMenuItem();
        jMenu10 = new javax.swing.JMenu();
        jMenu11 = new javax.swing.JMenu();
        jMenuItem29 = new javax.swing.JMenuItem();
        jMenuItem30 = new javax.swing.JMenuItem();
        jMenuItem31 = new javax.swing.JMenuItem();
        jMenuItem32 = new javax.swing.JMenuItem();
        jMenu12 = new javax.swing.JMenu();
        jMenuItem33 = new javax.swing.JMenuItem();
        jMenuItem34 = new javax.swing.JMenuItem();
        jMenuItem35 = new javax.swing.JMenuItem();
        jMenuItem36 = new javax.swing.JMenuItem();
        jMenu13 = new javax.swing.JMenu();
        jMenuItem37 = new javax.swing.JMenuItem();
        jMenu14 = new javax.swing.JMenu();
        jMenuItem38 = new javax.swing.JMenuItem();
        jMenuItem39 = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setName("mainPanel"); // NOI18N

        mScrollPane.setMinimumSize(new java.awt.Dimension(550, 280));
        mScrollPane.setPreferredSize(new java.awt.Dimension(550, 280));

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
        );

        menuBar.setName("menuBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(uczelniabd2.UczelniaBD2App.class).getContext().getResourceMap(UczelniaBD2View.class);
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(uczelniabd2.UczelniaBD2App.class).getContext().getActionMap(UczelniaBD2View.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setToolTipText(resourceMap.getString("exitMenuItem.toolTipText")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem1.setAction(actionMap.get("showStudentTable")); // NOI18N
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenu2.add(jMenuItem1);

        jMenuItem2.setAction(actionMap.get("showAddStudentBox")); // NOI18N
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenu2.add(jMenuItem2);

        jMenuItem3.setAction(actionMap.get("showEditStudentBox")); // NOI18N
        jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenu2.add(jMenuItem3);

        jMenuItem4.setAction(actionMap.get("showRemoveStudentBox")); // NOI18N
        jMenuItem4.setText(resourceMap.getString("jMenuItem4.text")); // NOI18N
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        jMenu2.add(jMenuItem4);

        jMenu1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N

        jMenuItem5.setAction(actionMap.get("showWykladowcaTable")); // NOI18N
        jMenuItem5.setText(resourceMap.getString("jMenuItem5.text")); // NOI18N
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        jMenu3.add(jMenuItem5);

        jMenuItem6.setAction(actionMap.get("showAddMajsterBox")); // NOI18N
        jMenuItem6.setText(resourceMap.getString("jMenuItem6.text")); // NOI18N
        jMenuItem6.setName("jMenuItem6"); // NOI18N
        jMenu3.add(jMenuItem6);

        jMenuItem7.setAction(actionMap.get("showEditMajsterBox")); // NOI18N
        jMenuItem7.setText(resourceMap.getString("jMenuItem7.text")); // NOI18N
        jMenuItem7.setName("jMenuItem7"); // NOI18N
        jMenu3.add(jMenuItem7);

        jMenuItem8.setAction(actionMap.get("showRemoveMajsterBox")); // NOI18N
        jMenuItem8.setText(resourceMap.getString("jMenuItem8.text")); // NOI18N
        jMenuItem8.setName("jMenuItem8"); // NOI18N
        jMenu3.add(jMenuItem8);

        jMenu1.add(jMenu3);

        menuBar.add(jMenu1);

        jMenu4.setText(resourceMap.getString("jMenu4.text")); // NOI18N
        jMenu4.setName("jMenu4"); // NOI18N

        jMenu5.setText(resourceMap.getString("jMenu5.text")); // NOI18N
        jMenu5.setName("jMenu5"); // NOI18N

        jMenuItem9.setAction(actionMap.get("showWydzialTable")); // NOI18N
        jMenuItem9.setText(resourceMap.getString("jMenuItem9.text")); // NOI18N
        jMenuItem9.setName("jMenuItem9"); // NOI18N
        jMenu5.add(jMenuItem9);

        jMenuItem10.setText(resourceMap.getString("jMenuItem10.text")); // NOI18N
        jMenuItem10.setName("jMenuItem10"); // NOI18N
        jMenu5.add(jMenuItem10);

        jMenuItem11.setText(resourceMap.getString("jMenuItem11.text")); // NOI18N
        jMenuItem11.setName("jMenuItem11"); // NOI18N
        jMenu5.add(jMenuItem11);

        jMenuItem12.setText(resourceMap.getString("jMenuItem12.text")); // NOI18N
        jMenuItem12.setName("jMenuItem12"); // NOI18N
        jMenu5.add(jMenuItem12);

        jMenu4.add(jMenu5);

        jMenu6.setText(resourceMap.getString("jMenu6.text")); // NOI18N
        jMenu6.setName("jMenu6"); // NOI18N

        jMenuItem13.setAction(actionMap.get("showInstytutTable")); // NOI18N
        jMenuItem13.setText(resourceMap.getString("jMenuItem13.text")); // NOI18N
        jMenuItem13.setName("jMenuItem13"); // NOI18N
        jMenu6.add(jMenuItem13);

        jMenuItem14.setText(resourceMap.getString("jMenuItem14.text")); // NOI18N
        jMenuItem14.setName("jMenuItem14"); // NOI18N
        jMenu6.add(jMenuItem14);

        jMenuItem15.setText(resourceMap.getString("jMenuItem15.text")); // NOI18N
        jMenuItem15.setName("jMenuItem15"); // NOI18N
        jMenu6.add(jMenuItem15);

        jMenuItem16.setText(resourceMap.getString("jMenuItem16.text")); // NOI18N
        jMenuItem16.setName("jMenuItem16"); // NOI18N
        jMenu6.add(jMenuItem16);

        jMenu4.add(jMenu6);

        jMenu7.setText(resourceMap.getString("jMenu7.text")); // NOI18N
        jMenu7.setName("jMenu7"); // NOI18N

        jMenuItem17.setAction(actionMap.get("showBudynekTable")); // NOI18N
        jMenuItem17.setText(resourceMap.getString("jMenuItem17.text")); // NOI18N
        jMenuItem17.setName("jMenuItem17"); // NOI18N
        jMenu7.add(jMenuItem17);

        jMenuItem18.setText(resourceMap.getString("jMenuItem18.text")); // NOI18N
        jMenuItem18.setName("jMenuItem18"); // NOI18N
        jMenu7.add(jMenuItem18);

        jMenuItem19.setText(resourceMap.getString("jMenuItem19.text")); // NOI18N
        jMenuItem19.setName("jMenuItem19"); // NOI18N
        jMenu7.add(jMenuItem19);

        jMenuItem20.setText(resourceMap.getString("jMenuItem20.text")); // NOI18N
        jMenuItem20.setName("jMenuItem20"); // NOI18N
        jMenu7.add(jMenuItem20);

        jMenu4.add(jMenu7);

        jMenu8.setText(resourceMap.getString("jMenu8.text")); // NOI18N
        jMenu8.setName("jMenu8"); // NOI18N

        jMenuItem21.setAction(actionMap.get("showSalaTable")); // NOI18N
        jMenuItem21.setText(resourceMap.getString("jMenuItem21.text")); // NOI18N
        jMenuItem21.setName("jMenuItem21"); // NOI18N
        jMenu8.add(jMenuItem21);

        jMenuItem22.setText(resourceMap.getString("jMenuItem22.text")); // NOI18N
        jMenuItem22.setName("jMenuItem22"); // NOI18N
        jMenu8.add(jMenuItem22);

        jMenuItem23.setText(resourceMap.getString("jMenuItem23.text")); // NOI18N
        jMenuItem23.setName("jMenuItem23"); // NOI18N
        jMenu8.add(jMenuItem23);

        jMenuItem24.setText(resourceMap.getString("jMenuItem24.text")); // NOI18N
        jMenuItem24.setName("jMenuItem24"); // NOI18N
        jMenu8.add(jMenuItem24);

        jMenu4.add(jMenu8);

        jMenu9.setText(resourceMap.getString("jMenu9.text")); // NOI18N
        jMenu9.setName("jMenu9"); // NOI18N

        jMenuItem25.setAction(actionMap.get("showSprzetTable")); // NOI18N
        jMenuItem25.setText(resourceMap.getString("jMenuItem25.text")); // NOI18N
        jMenuItem25.setName("jMenuItem25"); // NOI18N
        jMenu9.add(jMenuItem25);

        jMenuItem26.setText(resourceMap.getString("jMenuItem26.text")); // NOI18N
        jMenuItem26.setName("jMenuItem26"); // NOI18N
        jMenu9.add(jMenuItem26);

        jMenuItem27.setText(resourceMap.getString("jMenuItem27.text")); // NOI18N
        jMenuItem27.setName("jMenuItem27"); // NOI18N
        jMenu9.add(jMenuItem27);

        jMenuItem28.setText(resourceMap.getString("jMenuItem28.text")); // NOI18N
        jMenuItem28.setName("jMenuItem28"); // NOI18N
        jMenu9.add(jMenuItem28);

        jMenu4.add(jMenu9);

        menuBar.add(jMenu4);

        jMenu10.setText(resourceMap.getString("jMenu10.text")); // NOI18N
        jMenu10.setName("jMenu10"); // NOI18N

        jMenu11.setText(resourceMap.getString("jMenu11.text")); // NOI18N
        jMenu11.setName("jMenu11"); // NOI18N

        jMenuItem29.setAction(actionMap.get("showZajeciaTable")); // NOI18N
        jMenuItem29.setText(resourceMap.getString("jMenuItem29.text")); // NOI18N
        jMenuItem29.setName("jMenuItem29"); // NOI18N
        jMenu11.add(jMenuItem29);

        jMenuItem30.setText(resourceMap.getString("jMenuItem30.text")); // NOI18N
        jMenuItem30.setName("jMenuItem30"); // NOI18N
        jMenu11.add(jMenuItem30);

        jMenuItem31.setText(resourceMap.getString("jMenuItem31.text")); // NOI18N
        jMenuItem31.setName("jMenuItem31"); // NOI18N
        jMenu11.add(jMenuItem31);

        jMenuItem32.setText(resourceMap.getString("jMenuItem32.text")); // NOI18N
        jMenuItem32.setName("jMenuItem32"); // NOI18N
        jMenu11.add(jMenuItem32);

        jMenu10.add(jMenu11);

        jMenu12.setText(resourceMap.getString("jMenu12.text")); // NOI18N
        jMenu12.setName("jMenu12"); // NOI18N

        jMenuItem33.setAction(actionMap.get("showZapisyNaZajeciaTable")); // NOI18N
        jMenuItem33.setText(resourceMap.getString("jMenuItem33.text")); // NOI18N
        jMenuItem33.setName("jMenuItem33"); // NOI18N
        jMenu12.add(jMenuItem33);

        jMenuItem34.setText(resourceMap.getString("jMenuItem34.text")); // NOI18N
        jMenuItem34.setName("jMenuItem34"); // NOI18N
        jMenu12.add(jMenuItem34);

        jMenuItem35.setText(resourceMap.getString("jMenuItem35.text")); // NOI18N
        jMenuItem35.setName("jMenuItem35"); // NOI18N
        jMenu12.add(jMenuItem35);

        jMenuItem36.setText(resourceMap.getString("jMenuItem36.text")); // NOI18N
        jMenuItem36.setName("jMenuItem36"); // NOI18N
        jMenu12.add(jMenuItem36);

        jMenu10.add(jMenu12);

        menuBar.add(jMenu10);

        jMenu13.setText(resourceMap.getString("jMenu13.text")); // NOI18N
        jMenu13.setName("jMenu13"); // NOI18N

        jMenuItem37.setText(resourceMap.getString("jMenuItem37.text")); // NOI18N
        jMenuItem37.setName("jMenuItem37"); // NOI18N
        jMenu13.add(jMenuItem37);

        menuBar.add(jMenu13);

        jMenu14.setText(resourceMap.getString("jMenu14.text")); // NOI18N
        jMenu14.setName("jMenu14"); // NOI18N

        jMenuItem38.setText(resourceMap.getString("jMenuItem38.text")); // NOI18N
        jMenuItem38.setName("jMenuItem38"); // NOI18N
        jMenu14.add(jMenuItem38);

        jMenuItem39.setText(resourceMap.getString("jMenuItem39.text")); // NOI18N
        jMenuItem39.setName("jMenuItem39"); // NOI18N
        jMenu14.add(jMenuItem39);

        menuBar.add(jMenu14);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 378, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

	// <editor-fold defaultstate="collapsed" desc="Task'i przyciskow wyswietlania tabel">
	@Action
	public Task showStudentTable()
	{
		return new ShowStudentTableTask(getApplication());
	}
    private class ShowStudentTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowStudentTableTask(org.jdesktop.application.Application app)
		{
            super(app);
        }
        @Override protected Object doInBackground()
		{
            return prepareTable("STUDENT");
        }
        @Override protected void succeeded(Object result)
		{
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showWykladowcaTable()
	{
		return new ShowWykladowcaTableTask(getApplication());
	}
    private class ShowWykladowcaTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowWykladowcaTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("WYKLADOWCA");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showWydzialTable()
	{
		return new ShowWydzialTableTask(getApplication());
	}
    private class ShowWydzialTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowWydzialTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("WYDZIAL");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showInstytutTable()
	{
		return new ShowInstytutTableTask(getApplication());
	}
    private class ShowInstytutTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowInstytutTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("INSTYTUT");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showBudynekTable()
	{
		return new ShowBudynekTableTask(getApplication());
	}
    private class ShowBudynekTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowBudynekTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("BUDYNEK");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showSalaTable()
	{
		return new ShowSalaTableTask(getApplication());
	}
    private class ShowSalaTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowSalaTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("SALA");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showSprzetTable()
	{
		return new ShowSprzetTableTask(getApplication());
	}
    private class ShowSprzetTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowSprzetTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("SPRZET");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showZajeciaTable()
	{
		return new ShowZajeciaTableTask(getApplication());
	}
    private class ShowZajeciaTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowZajeciaTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("ZAJECIA");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }

	@Action
	public Task showZapisyNaZajeciaTable()
	{
		return new ShowZapisyNaZajeciaTableTask(getApplication());
	}
    private class ShowZapisyNaZajeciaTableTask extends org.jdesktop.application.Task<Object, Void> {
        ShowZapisyNaZajeciaTableTask(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
			return prepareTable("ZAPISYNAZAJECIA");
        }
        @Override protected void succeeded(Object result) {
			showTable((TableModel) result);
        }
    }
	// </editor-fold>
// =============================================================================
	// <editor-fold defaultstate="collapsed" desc="Variables">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu10;
    private javax.swing.JMenu jMenu11;
    private javax.swing.JMenu jMenu12;
    private javax.swing.JMenu jMenu13;
    private javax.swing.JMenu jMenu14;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenu jMenu9;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem17;
    private javax.swing.JMenuItem jMenuItem18;
    private javax.swing.JMenuItem jMenuItem19;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem20;
    private javax.swing.JMenuItem jMenuItem21;
    private javax.swing.JMenuItem jMenuItem22;
    private javax.swing.JMenuItem jMenuItem23;
    private javax.swing.JMenuItem jMenuItem24;
    private javax.swing.JMenuItem jMenuItem25;
    private javax.swing.JMenuItem jMenuItem26;
    private javax.swing.JMenuItem jMenuItem27;
    private javax.swing.JMenuItem jMenuItem28;
    private javax.swing.JMenuItem jMenuItem29;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem30;
    private javax.swing.JMenuItem jMenuItem31;
    private javax.swing.JMenuItem jMenuItem32;
    private javax.swing.JMenuItem jMenuItem33;
    private javax.swing.JMenuItem jMenuItem34;
    private javax.swing.JMenuItem jMenuItem35;
    private javax.swing.JMenuItem jMenuItem36;
    private javax.swing.JMenuItem jMenuItem37;
    private javax.swing.JMenuItem jMenuItem38;
    private javax.swing.JMenuItem jMenuItem39;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JScrollPane mScrollPane;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables
	// </editor-fold>
// =============================================================================
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
	public JDialog addStudentBox, editStudentBox, removeStudentBox;
	private JDialog addMajsterBox, editMajsterBox, removeMajsterBox;

	private JTable mJTable;

	private DatabaseMgr mDatabaseMgr;
}
